<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>子账号列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">
                <table class="layui-hide" id="test-table-reload" lay-filter="test-table-reload"></table>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="parentId" value="${parentId}">
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'utils'], function () {
        var $ = layui.$,
                table = layui.table,
                admin = layui.admin;

        //方法级渲染
        table.render({
            elem: '#test-table-reload'
            , url: "/merchant/getListByParentId?parentId=" + $("#parentId").val()
            , toolbar: '#test-table-reload-toolbar'
            , defaultToolbar: ['filter']
            , cellMinWidth: 80
            , cols: [[
                {field: 'id', title: '商家子账号ID', fixed: true}
                , {field: 'mobile', title: '手机号'}
                , {field: 'name', title: '子账号名称'}
                , {field: 'createTime', title: '创建时间', sort: true, templet: function (d) {
                        return "<div>" + layui.toDateString(d.createTime) + "</div>";
                    }}
                , {field: 'invalid', title: '状态', templet: invalid}
            ]]
            , page: true
            , height: 522
        });

        function invalid(data) {
            if(data.invalid === 0){
                return "<div>"+ "使用中"+"</div>";
            }
            if(data.invalid === 1){
                return "<div>"+ "已注销"+"</div>";
            }
        }

    });
</script>
</body>
</html>